# import requests

# vedio_url = "https://upos-sz-estgoss.bilivideo.com/upgcxcode/17/62/202426217/202426217-1-30066.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1710559878&gen=playurlv2&os=upos&oi=2005998830&trid=0655b0f310134f5fa44b30dc6285ae46u&mid=488665872&platform=pc&upsig=ca62c263f98800e765e6b097b452553c&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&bvc=vod&nettype=0&orderid=0,3&buvid=ACD382F7-53CA-A67D-38C2-3B62288B520E81236infoc&build=0&f=u_0_0&agrr=1&bw=146269&logo=80000000"
# audio_url = "https://cn-gdfs-ct-01-23.bilivideo.com/upgcxcode/17/62/202426217/202426217-1-30232.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1710561136&gen=playurlv2&os=bcache&oi=2005998830&trid=0000c64a127075a0429f8cfb8477c5a75601u&mid=488665872&platform=pc&upsig=aa7dc2248361e9aa0f077c1c4e89bf27&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&cdnid=60923&bvc=vod&nettype=0&orderid=0,3&buvid=ACD382F7-53CA-A67D-38C2-3B62288B520E81236infoc&build=0&f=u_0_0&agrr=1&bw=16627&logo=80000000"
# head={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36','Referer':'https://www.bilibili.com/video/BV1wD4y1Q7ui/?spm_id_from=333.337.search-card.all.click&vd_source=95d9f8017e7f424fcdf924b5459e4431'}

# vedio =requests.get(vedio_url,headers=head)
# audio = requests.get(audio_url,headers=head)

# open('vedio.mp4','wb').write(vedio.content)
# open('audio.mp3','wb').write(audio.content)

from moviepy.editor import *

# v=VideoFileClip('vedio.mp4')     #读取视频文件
# a=AudioFileClip('audio.mp3')     #读取音频文件
# v=v.set_audio(a)                 #将音频添加到视频中
# v.write_videofile('最终数据.mp4')   #输出视频文件
# 截取视频 = VideoFileClip('最终数据.mp4').subclip(98, 120)  # 截取视频的前10秒
# 截取视频.write_videofile('截取视频.mp4')  # 输出视频文件
# 水印处理
txt_clip = TextClip("demo测试", color='red', fontsize=72, bg_color='white')

# 定义水印位置
txt_clip = txt_clip.set_position(('right', 'top')).set_opacity(0.5).set_duration(10)

# 定义视频位置
video_clip = VideoFileClip('D:/python/2024python/截取视频.mp4')
# 合并视频和水印
final_clip = CompositeVideoClip([video_clip, txt_clip])

# 输出最终视频
final_clip.write_videofile('水印处理.mp4')
